import request from '@/utils/request'

// 获取服务列表
export function getServiceList(params) {
  return request({
    url: '/api/services',
    method: 'get',
    params
  })
}

// 获取服务详情
export function getServiceDetail(id) {
  return request({
    url: `/api/services/${id}`,
    method: 'get'
  })
}

// 创建服务
export function createService(data) {
  return request({
    url: '/api/services',
    method: 'post',
    data
  })
}

// 更新服务
export function updateService(id, data) {
  return request({
    url: `/api/services/${id}`,
    method: 'put',
    data
  })
}

// 删除服务
export function deleteService(id) {
  return request({
    url: `/api/services/${id}`,
    method: 'delete'
  })
}

// 获取预约列表
export function getAppointmentList(params) {
  return request({
    url: '/api/appointments',
    method: 'get',
    params
  })
}

// 获取预约详情
export function getAppointmentDetail(id) {
  return request({
    url: `/api/appointments/${id}`,
    method: 'get'
  })
}

// 创建预约
export function createAppointment(data) {
  return request({
    url: '/api/appointments',
    method: 'post',
    data
  })
}

// 更新预约状态
export function updateAppointmentStatus(id, status) {
  return request({
    url: `/api/appointments/${id}/status`,
    method: 'put',
    data: { status }
  })
}

// 取消预约
export function cancelAppointment(id) {
  return request({
    url: `/api/appointments/${id}/cancel`,
    method: 'put'
  })
}

// 创建评价
export function createReview(data) {
  return request({
    url: '/api/reviews',
    method: 'post',
    data
  })
}

// 获取服务评价列表
export function getServiceReviews(serviceId, params) {
  return request({
    url: `/api/services/${serviceId}/reviews`,
    method: 'get',
    params
  })
}

// 获取我的评价列表
export function getMyReviews(params) {
  return request({
    url: '/api/reviews/my',
    method: 'get',
    params
  })
}

// 更新评价
export function updateReview(id, data) {
  return request({
    url: `/api/reviews/${id}`,
    method: 'put',
    data
  })
}

// 删除评价
export function deleteReview(id) {
  return request({
    url: `/api/reviews/${id}`,
    method: 'delete'
  })
}

// 获取可用的预约时间段
export function getAvailableTimeSlots(serviceId, date) {
  return request({
    url: '/api/appointments/available-slots',
    method: 'get',
    params: { serviceId, date }
  })
} 